package com.mayikt.days03;

import java.util.concurrent.*;

/**
 * @ClassName Test004
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test004 {

    static class MayiktThread implements Callable<String> {
        @Override
        public String call() throws Exception {
            try {
                Thread.sleep(3000);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return "发送短信成功";
        }
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask = new FutureTask<>(new MayiktThread());
//        new Thread(futureTask).start();
//        String s = futureTask.get();
//        System.out.println("s:" + s);

        ExecutorService executorService =
                MayiktExecutor.newFixedThreadPool(10,
                        15, 5);
        Future<String> submit = (Future<String>) executorService.submit(futureTask);
        String value = submit.get();
        System.out.println(value);

    }
}
